<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增页面</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form" action="" method="post">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">id:</label>
                <div class="layui-input-block">
                    <input type="text" style="width: 400px"	 name="menuId" lay-verify="title" autocomplete="off" placeholder="请输入用户名称"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">菜单名称:</label>
                <div class="layui-input-block">
                    <input type="text" style="width: 400px" name="menuName" lay-verify="title" autocomplete="off" placeholder="请输入手机号码"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">登录账号:</label>
                <div class="layui-input-block">
                    <input type="text" style="width: 400px" name="loginName" lay-verify="title" autocomplete="off" placeholder="请输入登录账号"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户性别:</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="0" title="男" checked>
                    <input type="radio" name="sex" value="1" title="女">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">岗位:</label>
                <div class="layui-input-block">
                    <input type="text" style="width: 400px" name="remark" lay-verify="title" autocomplete="off" placeholder="请输入岗位"
                           class="layui-input">
                </div>
            </div>
            <%--				<div class="layui-form-item">--%>
            <%--					<label class="layui-form-label">角色:</label>--%>
            <%--					<div class="layui-input-block" style="width: 400px">--%>
            <%--						<select name="roleId" lay-filter="aihao">--%>
            <%--							<option  value=""></option>--%>
            <%--							<c:forEach var="realname" items="${sessionScope.roleByName}">--%>
            <%--								<option  value="${realname.roleId}">${realname.roleName}</option>--%>
            <%--							</c:forEach>--%>
            <%--						</select>--%>
            <%--					</div>--%>
            <%--				</div>--%>
            <div style="transform: translate(550px,-320px)">
                <div class="layui-form-item">
                    <label class="layui-form-label">归属部门:</label>
                    <div class="layui-input-block" style="width: 400px">
                        <select name="deptId" lay-filter="aihao">
                            <option  value=""></option>
                            <c:forEach var="deptByIdName" items="${sessionScope.sysDepts}">
                                <option  value="${deptByIdName.deptId}">${deptByIdName.deptName}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">邮箱:</label>
                    <div class="layui-input-block">
                        <input type="email" style="width: 400px" name="email" lay-verify="title" autocomplete="off" placeholder="请输入邮箱"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">登录密码:</label>
                    <div class="layui-input-block">
                        <input type="password" style="width: 400px" name="password" lay-verify="title" autocomplete="off" placeholder="请输入登录密码"
                               class="layui-input">
                    </div>
                </div>
                <%--					<div class="layui-form-item">--%>
                <%--						<label class="layui-form-label">用户状态:</label>--%>
                <%--						<div class="layui-input-block">--%>
                <%--							<input type="checkbox" checked="" name="status" lay-skin="switch" value="${requestScope.SysUser.status == 1 ? '正常' : '停用'}" lay-filter="switchTest" lay-text="ON|OFF">--%>
                <%--						</div>--%>
                <%--					</div>--%>
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">用户类型:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="userType" value="00" title="系统用户" checked="">
                        <input type="radio" name="userType" value="01" title="注册用户">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="${pageContext.request.contextPath}/statics/component/layui/layui.js"></script>
<script src="${pageContext.request.contextPath}/statics/component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery'], function() {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(user-save)', function(data) {
            $.ajax({
                url: '${pageContext.request.contextPath}/user/add',
                data: data.field,
                dataType: 'json',
                // contentType: 'application/json',
                type: 'post',
                success: function(result) {
                    if (result === 1) {
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            parent.layer.close(parent.layer.getFrameIndex(window
                                .name)); //关闭当前页
                            parent.layui.table.reload("user-table");
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>